//
//  UserInfoHeaderView.m
//  Lucky28
//
//  Created by zr on 2018/8/1.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "UserInfoHeaderView.h"

@interface UserInfoHeaderView ()

@property(nonatomic, weak)UIImageView * rightImageView;
@property (nonatomic, weak)UIView * lineView;

@end

@implementation UserInfoHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}


- (void)setupUI{
    
    self.backgroundColor = [UIColor whiteColor];
    
    self.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    
    [self addGestureRecognizer:tapGR];
    
    UIImageView * iconImageView = [UIImageView new];
    
    //  给图片加一个圆形边框
    iconImageView.layer.borderWidth = 1.5f;//边框宽度
    iconImageView.layer.borderColor = ColorWithRGB(0xFAAFB9).CGColor;//边框颜色
    //  把图片设置成圆形
    iconImageView.layer.cornerRadius = 40;//裁成圆角
    iconImageView.layer.masksToBounds = YES;//隐藏裁剪掉的部分
    
    iconImageView.image = ImageNamed(@"头像7");
    
    self.iconImageView = iconImageView;
    
    [self addSubview:self.iconImageView];
    
    
    UIImageView * rightImageView = [UIImageView new];
    
    rightImageView.image = ImageNamed(@"gengduo");
    self.rightImageView = rightImageView;
    
    [self.contentView addSubview:self.rightImageView];
    
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0XE4E4E4);
    
    self.lineView = lineView;
    
    [self.contentView addSubview:self.lineView];
}


- (void)layoutSubviews{
    
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.mas_equalTo(80 * SCREENH6);
        make.leading.mas_equalTo(self).offset(20 * SCREENH6);
        make.top.mas_equalTo(self).offset(10 * SCREENH6);
    }];
    
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.iconImageView);
        make.trailing.mas_equalTo(self).offset(-15 * SCREENH6);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.mas_equalTo(self);
        make.height.mas_equalTo(1 * SCREENH6);
    }];
}


- (void)tapAction{
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"GetPicture" object:nil];
}


@end
